package com.java.comprehensive.arithmetic.leecode.tags.tree;

import util.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Dgg
 * @Date: 2021/12/28 20:00
 */
public class LeetCode_94 {
	/**
	 * Definition for a binary tree node.
	 * public class TreeNode {
	 * int val;
	 * TreeNode left;
	 * TreeNode right;
	 * TreeNode() {}
	 * TreeNode(int val) { this.val = val; }
	 * TreeNode(int val, TreeNode left, TreeNode right) {
	 * this.val = val;
	 * this.left = left;
	 * this.right = right;
	 * }
	 * }
	 */
	public List<Integer> inorderTraversal(TreeNode root) {
		List<Integer> list = new ArrayList<>();
		if (root == null) {
			return list;
		}
		getTree(root, list);
		return list;
	}

	public static void getTree(TreeNode root, List<Integer> list) {
		if (root == null) {
			return;
		}

		getTree(root.left, list);

		list.add(root.val);

		getTree(root.right, list);

	}

}
